package com.xiaotu.server.service.maoyan;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.xiaotu.common.model.*;
import org.springframework.stereotype.Service;

import com.xiaotu.server.service.BaseService;
/***
 * 
 * @author Administrator
 *
 */
@Service
public class MaoYanMovieBasicInfoService extends BaseService{

	@Override
	protected String getKey() {
		return "MaoYanMovieBasicInfoMapper";
	}
	   
	public MaoYanMovieBasicInfoModel queryMovieBasicInfoList(Map<String,Object> param){
		return this.get("queryMovieBasicInfoList",param);
	}
	
	public List<MaoYanMovieBasicInfoModel> queryMovieBasicInfoList(List<MaoYanMovieBasicInfoModel> param){
		return this.getList("queryMovieBasicInfoListByIds",param);
	}
	
	public int updateBatchMovieBasicInfo(List<MaoYanMovieBasicInfoModel> param,List<MaoYanMovieRecordOnlineModel> maoYanMovieRecordOnlineModelList){
		if(maoYanMovieRecordOnlineModelList.size()>0){
			saveBatchMovieRecordOnline(maoYanMovieRecordOnlineModelList);
		}
		return this.update("batchUpdMovieBasicInfo",param);
	}

	public List<MaoYanMovieBasicInfoModel> queryMovieOffLineList() {
		return this.getList("queryMovieOffLineList");
	}
	
	public List<MaoYanMovieRecordLineModel> queryMovieOffLineListByRecordLineTable() {
		return this.getList("queryMovieOffLineListByRecordLineTable");
	}

	public Map<String,String> queryMovieExistList(List<Map<String, Object>> movList) {
		
		Map<String,String> map = new HashMap<String,String>();
		List<MaoYanMovieBasicInfoModel> list = this.getList("queryMovieExistList",movList);
		for(MaoYanMovieBasicInfoModel model : list){
			String dataId = model.getDataid();
			String tvId = model.getId();
			if(!map.containsKey(dataId)){
				map.put(dataId, tvId);
			}
		}
		return map;
	}
	
	public int saveBatchMovieRecordOnline(List<MaoYanMovieRecordOnlineModel> param){
		return this.update("saveBatchMovieRecordOnline",param);
	}
	//保存数据库
	public void saveMovieBasicInfo(MaoYanMovieSupplementBasicInfoModel maoYanMovieBasicInfoModel) {
		this.update("saveMovieBasicInfo",maoYanMovieBasicInfoModel);
	}
	//用于补充主创人员信息
	public List<Map<String, Object>> queryMovieBasicInfoList() {
		return this.getList("queryMovieBasicInfoForSupplementPeopleList",null);
	}

	//查询已存在艺人表中的数据
	public List<StarTvWorksModel> queryExitsStarInfoList(List<StarTvWorksModel> starTvWorksModelList) {
		if(starTvWorksModelList.size()>0){
			return this.getList("queryExitsStarInfoList",starTvWorksModelList);
		}
		return new ArrayList<StarTvWorksModel>();
	}
	//查询已存在公司表中的数据
	public List<CompanyTvWorksModel> queryExitsCompanysInfoList(List<CompanyTvWorksModel> companyTvWorksModelList) {
		if(companyTvWorksModelList.size()>0){
			return this.getList("queryExitsCompanysInfoList",companyTvWorksModelList);
		}
		return new ArrayList<CompanyTvWorksModel>();
	}
	
	//查询猫眼电影未达到分账周期列表 
	public List<MaoYanMovieBasicInfoModel> queryNotYetAchievedCycleDate(){
		return this.getList("queryNotYetAchievedCycleDate");
	}

	//查询需要爬取猫眼评分的网大
	public List<MaoYanMovieBasicInfoModel> arriveYetAchievedCycleDateList() {
		return this.getList("arriveYetAchievedCycleDateList");
	}
	
	//获取电影票房信息
	public List<Map<String, Object>> queryMovieBoxOfficeList() {
		return this.getList("queryMovieBoxOfficeList",null);
	}
	
	//获取电影票房明细
	public List<Map<String, Object>> queryBoxOfficeDetailList() {
		return this.getList("queryBoxOfficeDetailList",null);
	}

	/** queryBoxMovieList(临时sql)   
	 * 创建人：张晓   
	 * 创建时间：2020年3月4日 下午1:57:25    
	 * 修改备注： 
	 * @return  
	 */
	public List<Map<String, Object>> queryBoxMovieList() {
		return this.getList("queryBoxMovieList");
	}

	/** getNetTvInfoList(猫眼网大基础信息)   
	 * 创建人：张晓   
	 * 创建时间：2020年3月23日 下午2:33:18    
	 * 修改备注： 
	 * @return  
	 */
	public List<Map<String, Object>> getNetTvInfoList(String siteName) {
		Map<String,Object> param = new HashMap<String,Object>();
		param.put("siteName", siteName);
		return this.getList("getNetTvInfoList",param);
	}

	/**
	 *
	 * @param param
	 * @return
	 */
	public int saveBatchNetTVRecordS(List<NetTVRecordsModel> param){
		return this.update("saveBatchNetTVRecordS",param);
	}
	
}
